import time


class FrameRates:
    """
    帧率计算算法
    """

    def __init__(self):
        self.q = []

    def record(self):
        self.q.append(time.time())
        while time.time() - self.q[0] > 1:
            self.q.pop(0)

    def get_fps(self):
        return len(self.q)
